

#import <Cocoa/Cocoa.h>

#import "objcExt.h"
#include "objc/objc-class.h"

id watchedObject=nil;

#if 0

@interface NSView (Watchrelease)
- (void) release;
@end

@implementation NSView (Watchrelease)
- (void) release
{
	if (watchedObject==self) {
		NSLog(@"beeing released\n");
	}
	//[super release];
}

@end
#endif



Class * getAllClasses(int *numClasses)
{
	Class * classes;
	*numClasses = objc_getClassList(NULL, 0);
	if( *numClasses <= 0 ) return NULL;
	classes = NSZoneMalloc(NSDefaultMallocZone(), sizeof(Class) * *numClasses );
	(void) objc_getClassList( classes, *numClasses );
	return classes;
}


NSArray *getAllSubclassesOf(Class p)
{
	Class * rgClass;
	int nc;
	rgClass = getAllClasses(&nc);
	if (!rgClass) return nil;
	int i;
	NSMutableArray *ca;
	ca=[NSMutableArray arrayWithCapacity:nc/2];
	for (i=0; i<nc; i++) {
		if (rgClass[i]==p) continue;
		if (!isSubclassOf(rgClass[i], p)) continue;
		[ca addObject:rgClass[i]];
	}
	NSZoneFree(NSDefaultMallocZone(), rgClass);
	return ca;
}


